package com.park.service.impl;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.park.dao.StatisticDataDAO;
import com.park.model.Constants;
import com.park.model.StatisticData;
import com.park.service.StatisticDataService;

//@Transactional
@Service
public class StatisticDataServiceImpl implements StatisticDataService {

	@Autowired
	StatisticDataDAO staticticDataDao;



	@Override
	public StatisticData selectstatisticDataByPerioid(Date startDay, Date endDay) {
		// TODO Auto-generated method stub
		return staticticDataDao.selectstatisticDataByPerioid(startDay, endDay);
	}
	@Override
	public StatisticData selectstatisticDataByPark(Date startDay, Date endDay, int parkId) {
		// TODO Auto-generated method stub
		return staticticDataDao.selectstatisticDataByPark(startDay, endDay,parkId);
	}
	@Override
	public List<StatisticData> selectstatisticDataByParkAndRange(Date startDay, Date endDay, int parkId) {
		// TODO Auto-generated method stub
		SimpleDateFormat sFormat=new SimpleDateFormat(Constants.DATEFORMAT);
		System.out.println(String.format("wxq: startDay:%s,endDate:%s\n",sFormat.format(startDay),sFormat.format(endDay).toString()));
		return staticticDataDao.selectstatisticDataByParkAndRange(startDay, endDay, parkId);
	}

	@Override
	public List<StatisticData> selectstatisticDataByParkAndRangeData(String date, int parkId) throws ParseException {
		// TODO Auto-generated method stub
		SimpleDateFormat sFormat=new SimpleDateFormat(Constants.DATEFORMAT);
		Date startDay=sFormat.parse(date+" 00:00:00");
		Date endDay=sFormat.parse(date+" 23:59:59");
		return staticticDataDao.selectstatisticDataByParkAndRange(startDay,endDay, parkId);
	}

	@Override
	public List<StatisticData> selectstatisticExcel(int parkId, String startDate, String endDate) {
		// TODO Auto-generated method stub
		return staticticDataDao.selectstatisticExcel(parkId, startDate, endDate);
	}
	@Override
	public StatisticData selectstatisticDataByYestDay(String username,Date yestStartDay,Date yestEndDay) {
		// TODO Auto-generated method stub
		return staticticDataDao.selectstatisticDataByYestDay(username,yestStartDay,yestEndDay);
	}

}
